package leetcode.每日一题;

import org.junit.Test;

import java.util.*;

/**
 * @author ：zsy
 * @date ：Created 2021/6/21 9:28
 * @description：https://leetcode-cn.com/problems/binary-watch/
 */
public class 二进制手表 {
    @Test
    public void test() {
        Solution solution = new Solution();
        System.out.println(solution.readBinaryWatch(8));

    }

    class Solution {
        public List<String> readBinaryWatch(int turnedOn) {
            List<String> ans = new ArrayList<String>();
            for (int i = 0; i < 1024; i++) {
                int h = i >> 6;
                int m = i & 63;
                if (h < 12 && m < 60 && Integer.bitCount(i) == turnedOn) {
                    ans.add(h + ":" + (m < 10 ? "0" : "") + m);
                }
            }
            return ans;
        }
    }
}
